import website from "@/config/website";
import {defineStore} from 'pinia'



export default  defineStore('commonStore', {
    state: () => {
        return {
            language: "zh-cn",
            isCollapse: false,
            menuCollapse: false,
            isFullScreen: false,
            isMenu: true,
            isSearch: false,
            isRefresh: true,
            isLock: false,
            themeName: 'default',
            lockPasswd: '',
            website: website,
            setting: website.setting,

        }
    },
    getters: {
        isHorizontal: (state) => state.setting.sidebar === 'horizontal',
        isMacOs: state => state.themeName === 'mac-os',
    },
    actions: {
        setLanguage(language) {
            this.language = language;
        },
        toggleCollapse() {
            this.isCollapse = !this.isCollapse;
        },
        setIsMenu(menu) {
            this.isMenu = menu;
        },
        setIsRefresh(refresh) {
            this.isRefresh = refresh;
        },
        setIsSearch(search) {
            this.isSearch = search;
        },
        toggleFullscreen() {
            this.isFullScreen = !this.isFullScreen;
        },
        lockScreen() {
            this.isLock = true;
        },
        setThemeName(themeName) {
            this.themeName = themeName;

        },
        setLockPasswd(lockPasswd) {
            this.lockPasswd = lockPasswd;

        },
        clearLockScreen() {
            this.isLock = false;
            this.lockPasswd = '';
        },
    },

})


